Skip to content

Initial commit, add base structure, vue frontend + backend#1

Open
maxtaube wants to merge 21 commits into
5.x-devfrom
ID-35-create-AIProviders-plugin
Open

Initial commit, add base structure, vue frontend + backend#1
maxtaube wants to merge 21 commits into
5.x-devfrom
ID-35-create-AIProviders-plugin

Conversation

@maxtaube

@maxtaube maxtaube commented May 20, 2026

Copy link
Copy Markdown
Collaborator

Description:

Adds the AIProviders plugin, which gives Matomo a shared server-side integration layer for AI features. It supports Anthropic, OpenAI, Google, and OpenAI-compatible custom endpoints, with an admin UI for self-managed instances to configure credentials, default provider, model settings, and connection tests.

Other plugins should not call completion endpoints through API.php; those methods are only for the administration UI. Runtime use goes through AIProviderService:

  • complete(new AIRequest($prompt, $callerPlugin)) for prompt-in/text-out or JSON responses.
  • converse(new AIConversationRequest($messages, $callerPlugin)) for multi-turn conversations and tool-calling flows.

Requests use immutable request objects for:

  • caller and feature metadata
  • provider/model hints
  • generation options such as max tokens and temperature
  • JSON mode for simple completions
  • optional site context for completion requests
  • tool catalogs for conversation requests

Conversation messages use a provider-agnostic canonical shape, and each provider translates that shape to its own wire format. Responses expose text/content, provider/model metadata, token usage where available, stop reason, and timing.

Self-managed instances can configure providers in the UI or via server-side configuration. In a managed environment, provider configuration is locked server-side, the admin screen is hidden, and normal plugin requests are routed through the managed default provider. Provider/model selection is only honored for selected trusted server-side callers.

A custom provider can either be configured through the built-in Custom Provider option in the UI, using an OpenAI-compatible base URL plus an optional API key, or registered by another plugin via the AIProviders.addAIProviders event with a custom AIProvider class.

Includes unit and integration coverage for configuration resolution, managed-environment behavior, provider registration, completion requests, JSON responses, conversation support, and provider-specific request/response translation.

image

Review

  • Functional review done
  • Potential edge cases thought about (behavior of the code with strange input, with strange internal state or possible interactions with other Matomo subsystems)
  • Usability review done (is anything maybe unclear or think about anything that would cause people to reach out to support)
  • Security review done see checklist
  • Code review done
  • Tests were added if useful/possible
  • Reviewed for breaking changes
  • Developer changelog updated if needed
  • Documentation added if needed
  • Existing documentation updated if needed

@maxtaube maxtaube marked this pull request as ready for review June 9, 2026 07:48
maxtaube and others added 3 commits June 10, 2026 13:07
Support JSON completion requests across providers, expose decoded JSON responses, prevent duplicate provider registrations, and hide AI provider settings in managed environments.
@maxtaube maxtaube requested a review from a team June 18, 2026 00:00
maxtaube added 2 commits June 18, 2026 11:03
Add AIProvider exception hierarchy, properly implemented test connection function, fixed custom provider model implementation, dropped rawReponse key from the AIProviderResponse
Add converse() methods for plugins that need conversations with tool calling. Added canonical message shapes
Comment thread lang/en.json Outdated
Comment thread .gitignore
Comment thread plugin.json Outdated
Comment thread API.php Outdated
Comment thread AIProviders.php
Comment thread vue/src/ManageAIProviders.vue
Comment thread vue/src/ManageAIProviders.vue
Comment thread README.md
Comment thread tests/Integration/ConverseServiceTest.php Outdated
Comment thread Provider/AIProvider.php Outdated
@maxtaube maxtaube changed the title Initial commit, add base structure, vue frontend Initial commit, add base structure, vue frontend + backend Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants